/*
 * @Author: yanjikun
 * @Date: 2022-03-22 11:27:34
 * @LastEditors: yanjikun
 * @LastEditTime: 2022-05-06 10:45:30
 * @Description: file content
 */

import { tableProps } from 'ant-design-vue/lib/table'
import { PropType } from 'vue'
import { TableColumn } from './types/column'
import { ExtractPropTypes } from 'vue'
import { OnChangeCallbackParams } from './types/table'
import DynamicTable from '..'

export const dynamicTableProps = {
  ...tableProps(),
  /**表格列配置 */
  columns: {
    type: Array as PropType<TableColumn<any>[]>,
    required: true,
    default: () => [],
  },
  /**表格数据请求函数 */
  dataRequest: {
    type: Function as PropType<(params: any) => Promise<API.TableListType>>,
  },
  /** 是否显示索引号 */
  showIndex: {
    type: Boolean as PropType<boolean>,
    default: false,
  },
  /** 索引列属性配置 */
  indexColumnProps: {
    type: Object as PropType<Partial<TableColumn>>,
    default: () => ({}),
  },
  /**高度是否自适应 */
  heightAdaptation: {
    type: Boolean as PropType<boolean>,
    default: true,
  },
}

export type DynamicTableProps = ExtractPropTypes<typeof dynamicTableProps>

export type DynamicTableEmits = {
  (event: 'change', data: Parameters<NonNullable<OnChangeCallbackParams>>): void
}
export type DynamicTableInstance = InstanceType<typeof DynamicTable>

/** 默认支持的插槽 */
export const defaultSlots = [
  'emptyText',
  'expandIcon',
  'title',
  'footer',
  'summary',
  'expandedRowRender',
  'customFilterIcon',
  'customFilterDropdown',
] as const
